package com.best.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.best.weiyi.R;
import com.best.weiyi.entity.Song;

public class SearchMusicListAdapter extends BaseAdapter{
	private Context mContext;
	public static List<Song> list;
	public SearchMusicListAdapter(Context mContext,List<Song> list){
		this.mContext = mContext;
		this.list = list;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		Song song = list.get(arg0);
		ViewHolder view = null;
		if(arg1 == null){
			view = new ViewHolder();
			arg1 = LayoutInflater.from(mContext).inflate(R.layout.search_musiclist_item, null);
			view.showName = (TextView) arg1.findViewById(R.id.list_name);
			view.showSinger = (TextView) arg1.findViewById(R.id.list_singer);
			arg1.setTag(view);
		}else{
			view = (ViewHolder) arg1.getTag();
		}
		view.showName.setText(song.getSong());
		view.showSinger.setText(song.getSinger());
		return arg1;
	}
	public class ViewHolder{
		TextView showName,showSinger;
	}
	
}